package com.hr.builder;

import org.springframework.stereotype.Component;

import com.espirit.eap.manager.ModelBuilderSupport;
import com.espirit.eap.manager.RelatedModel;
import com.espirit.eap.manager.TabbedModel;
import com.espirit.eap.pagelayout.FunctionButton;
import com.hr.BankCollection;
import com.hr.BankCollectionItem;

@Component
public class BankCollectionBuilder extends ModelBuilderSupport {
	static final String ACCTTERM= "acctTerm";
	static final String ITEMCOUNTS = "itemCounts";
	static final String AMOUNT = "amount";
	static final String STATE = "state";
	static final String CREATEDON = "createdOn";
	static final String CREATED = "created";
//	static final String IDS = "ids";
	
	
	@Override
	public boolean init() {
		return super.setClass(BankCollection.class, "Bank Collection ", "银行托收");
	}

	@Override
	public void buildFields() {
		super.buildFields();
		addModelField(ITEMCOUNTS, "Emps", "人数");
		addModelField(AMOUNT, "Amount", "总金额");
		addModelField(ACCTTERM, "Acct Term", "会计期间");
		addModelField(STATE, "State", "状态");
//		addModelField(IDS, "Selected Ids", "Selected Ids");
		addModelField(CREATED, "Creat", "创建");
		addModelField(CREATEDON, "Created", "创建日期");
	}
	
	@Override

	protected void setDefaultLayoutButtons() {
		addButton(FunctionButton.DELETE);
		addButton(FunctionButton.EXPORT);
	}
	
	@Override
	protected void addSearchFields() {
		super.addSearchField(convertPropertyToField(ACCTTERM));
	}
	
	@Override
	protected void addListFields() {
		addListField(convertPropertyToField(STATE, ACCTTERM, ITEMCOUNTS, AMOUNT, CREATED, CREATEDON ));
	}
	
	@Override
	protected void addDetailFields() {
		addDetailField(convertPropertyToField(ACCTTERM, STATE, ITEMCOUNTS, AMOUNT));
	}
	
	protected RelatedModel[] getRelatedModels(){
		RelatedModel getLayout = new RelatedModel(this.clazz, "getLayout");
		return new RelatedModel[]{getLayout};
	}
	
	protected TabbedModel[] getTabbedModels(){
		TabbedModel items = new TabbedModel(BankCollectionItem.class, SEARCH, "parent");
		return new TabbedModel[]{items};
	}
	
}
